#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <fcntl.h>
#include <sys/wait.h>

int
main(int argc, char *argv[])
{
	printf("hello world (pid:%d)\n", (int)getpid());
	int rc =fork();
	if(rc < 0){
		fprintf(stderr, "fork failed\n");
		exit(1);
	}else if(rc == 0){
		//int wc = wait(NULL);
		int wc = 0;
		printf("child: hello wait return : %d (pid:%d)\n", wc, (int)getpid());
	}else{
		//int wc = wait(NULL);
		int wc = waitpid(-1 ,NULL, WNOHANG);
		//int wc = 0;
		printf("wait return : %d parent: goodbye! (pid:%d) \n", wc, (int)getpid());
	}

	return 0;
}
